﻿Imports System.Windows.Forms

Public Class DatagridViewEdComboBoxColumn
    Inherits DataGridViewColumn

    Protected iList As New Collections.ObjectModel.Collection(Of Object)

    Public ReadOnly Property Items As Collections.ObjectModel.Collection(Of Object)
        Get
            Return Me.iList
        End Get
    End Property

    Public Sub New()
        MyBase.New(New DatagridViewEdComboBoxCell)
    End Sub

    Public Overrides Property CellTemplate As System.Windows.Forms.DataGridViewCell
        Get
            Return MyBase.CellTemplate
        End Get
        Set(value As System.Windows.Forms.DataGridViewCell)
            If (value IsNot Nothing) AndAlso (value.GetType().IsAssignableFrom(GetType(DatagridViewEdComboBoxCell))) Then
                Dim s As String = "Cell type is not based upon the DatagridViewEdComboBoxCell."
                Throw New InvalidCastException(s)
            End If
            MyBase.CellTemplate = value
        End Set
    End Property

    Public Function ItemCount() As Integer
        Return Me.iList.Count
    End Function

End Class
